package dbTest.connectionPool;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;

public class StarsDAO
{
	private static StarsDAO starsDAO = null;
	ConnectionPool connectionPool;
	Connection conn;
	
	public static synchronized StarsDAO getIstance() throws ConnectionPoolException
	{
		if (starsDAO == null)
		{
			starsDAO = new StarsDAO();
		}
		return starsDAO;
	}

	private StarsDAO() throws ConnectionPoolException
	{
		connectionPool=ConnectionPool.getConnectionPool();
		conn=connectionPool.getConnection();
	}

	public ArrayList<Stars> getStarsAll() throws Exception
	{

		ArrayList<Stars> res = new ArrayList<Stars>();
		Statement statement = conn.createStatement();  
        ResultSet resultSet = statement.executeQuery("SELECT * FROM stars");  
        while (resultSet.next()) 
        {  
        	res.add((Stars)BeanFactory.getObj(new Stars().getClass().getName(), resultSet));
        }  
        connectionPool.releaseConnection(conn);
        
		return null;
	}

}
